﻿using Dapper;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using YinfangWeb.BLL.Enum;
using YinfangWeb.BLL.Model;
using YinfangWeb.Model;

namespace YinfangWeb.DAL
{
    public partial class UserRightItemDAO
    {
        #region 获取 权限 一级
        /// <summary>
		/// 获取 权限 一级
		/// </summary>
		/// <returns>实体列表</returns>
        public List<dynamic> GetListLevelfirst()
        {
            var sql = "SELECT UserRightItemID, RightName FROM UserRightItem where (UserRightItemID % 1000 = 0) order by RightOrder";
            using (var conn = ConnectionFactory.CreateConnection())
            {
                var q = conn.Query<dynamic>(sql);
                return q.ToList();
            }
        }
        #endregion
        #region 获取 权限 二级
        /// <summary>
		/// 获取 权限 二级
		/// </summary>
		/// <returns>实体列表</returns>
        public List<dynamic> GetListLevelsecond(int levelfirst)
        {
            string where = $" where (UserRightItemID between {(levelfirst+1).ToString()} and {(levelfirst + 999).ToString()})";
            var sql = $"SELECT UserRightItemID, RightName FROM UserRightItem {where} order by RightOrder";
            using (var conn = ConnectionFactory.CreateConnection())
            {
                var q = conn.Query<dynamic>(sql);
                return q.ToList();
            }
        }
        #endregion
    }
}
